{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Truncation Error vs Rounding Error"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "In this notebook, we'll investigate two common sources of error: Truncation error and rounding error."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as pt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Task:** Approximate a function (here: a parabola, by a line)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "(-28.0, 2.2497704315886136)"
            ]
          },
          "execution_count": 15,
          "metadata": {},
          "output_type": "execute_result"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD7CAYAAACPDORaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4lFX6xvHvAWHZH6AoIgooooIKJjQFBYWINBERC7uw\nCktAqrquXUExIkrRBQTpRRFFREUCUoMQekIJkKBUqSK9iiGkzPn98UY3roEkZGbemcn9ua65kmnv\neeYKuXly5sx5jbUWEREJTYXcLkBERHxHIS8iEsIU8iIiIUwhLyISwhTyIiIhTCEvIhLCLnG7AGOM\n1nCKiFwEa63J6TGuhzxAKK/Vj4qKIioqyu0yfEavL7jl9PqstXy84WNeWfgKPe/oSa97elG0cFH/\nFZiDX36BzZudy7ZtsH2783XnTkhLi6JatSgqVoTrrnMu114L5co5l6uvhmLF3H4F2fN44PhxOHAA\n9u+Hn36Cfftg717Yswd274Zdu3LMdyBAQl5EAs++U/vo+m1XDp45yIL2C6hxdQ3XaklPhy1bIDHx\nv5dNm+DYMbjlFudy883wyCNQuTLceCMMHQrB+v9zoUJw5ZXOJSws+8eY3GW8Ql5E/shay/iE8fRa\n1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bMr8/A2wGyp/v8QHxYShjTCtgn7U2yYTo/sLGmH5AB+AkcK/L5fhSJ5zQkMBVHtiX\n5fpPOMEvQcYYcz1QA4g/32P8FvLGmBgg6wbCBrDA60AvnKmarPcFlQu8vt7W2lnW2teB1zPnP58B\novxf5cXL6fVlPqY3kGatneJCiRctN69NJNAYY0oAXwHP/s9swR/4LeSttU2yu90YcxtwPbDROG18\nBWCdMaaOtfawv+rLr/O9vmxMAeYQZCGf0+szxnQEWgCN/FKQF+XhZxcq9gPXZbleIfM2CRLGmEtw\nAn6ytTb6Qo91fbrGWrsJ+H21iTFmF1DLWhsyc2rGmJustTsyr7bGmUMLGcaY5jjvpzSw1p5zux4f\nCrq/MM9jDXCTMaYicABoC7RztySvM4TOzys7E4EfrLUf5PTAQHrj9TeW0PvhDDDGJBpjNgCNgWfd\nLsjLhgMlgBhjTIIxZqTbBXmLMaa1MWYfcCfwrTFmrts15Ze1NgN4GmdV1PfAVGttyDQexpgpwEqg\nijFmrzEm0u2avMkYUx94HGiUuSw7IbPRyv7x2tZARCR0BWInLyIiXqKQFxEJYQp5EZEQppAXEQlh\nCnkRkRCmkBcRCWEKeRGREKaQFxEJYf8PBAJm/JrSotYAAAAASUVORK5CYII=\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f35e995a7f0>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "center = -1\n",
        "width = 6\n",
        "\n",
        "def f(x):\n",
        "    return - x**2 + 3*x\n",
        "\n",
        "def df(x):\n",
        "    return -2*x + 3\n",
        "\n",
        "grid = np.linspace(center-width/2, center+width/2, 100)\n",
        "\n",
        "fx = f(grid)\n",
        "pt.plot(grid, fx)\n",
        "pt.plot(grid, f(center) + df(center) * (grid-center))\n",
        "\n",
        "pt.xlim([grid[0], grid[-1]])\n",
        "pt.ylim([np.min(fx), np.max(fx)])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "* What's the error we see?\n",
        "* What if we make `width` smaller?"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": true
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.0+"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}